let mysqlConnection = require("./mysqlConfig")


module.exports = {
    selectUserNightMode: function (id) {
        return new Promise((resolve,reject) => {
        let selectUserNightModeSQL = `select user_nightmode.status from user_nightmode where user_id = ${id}`;
        mysqlConnection.query(selectUserNightModeSQL, function (error, results) {
            resolve(results);
        })
        })
    },
    updateUserNightMode: function (userid,status) {
        return new Promise((resolve,reject) => {
        let updateUserNightModeSQL = `UPDATE tasks.user_nightmode t SET t.status = ${status} WHERE t.user_id = ${userid}`
        mysqlConnection.query(updateUserNightModeSQL, function (error, results) {
            if (error) {
                reject(error)
            }
            else {resolve(results)}
        })
        })
    }
}